<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors','On');
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 *  Home Class  
 *  
 * @package CMS v2.0 
 * @subpackage News  
 * @author Vui Nguyen - 09/04/2013
 * @link http://joomlavui.info
 */
class Shop extends CI_Controller {

    /**
     * Contrust class
     *  
     * @access public 
     */
    public function __construct() {
		
        parent::__construct();
        $this->load->helper('url');		                
        $this->load->library('smarty3', '', 'smarty');        
        $this->load->library('captcha');
        $this->load->library('session');
        $this->load->library('email');
        // load models user,billing
        $this->load->model('kpay/db_user_model');
        $this->db_user_model		= new db_user_model();
        $this->load->model('kpay/db_billing_model');
        $this->db_billing_model		= new db_billing_model();
        //
        include APPPATH . 'libraries/pay/login_service.php';        
        $this->login_lib 		= new login_service();
        //		
    }
    public function index(){
       //$this->smarty                                                            
       //             ->display('template/shop/home'); 
        $user = $this->session->userdata('user_info');
        if($user)
            $this->smarty->assign('user_info',$user);
        //$this->smarty->assign('menu','contact');
        $this->smarty   ->view('template/pages_live/partner','partner')
                        ->view('template/pages_live/shop','content')
                        ->display('template/frontend_live/home'); 
    }
    // SHOP BUY CARD WHEN NOT LOGINED
    public function paygate_buycard($productID=null,$cardPrice=null,$quantity=null) {
        //        
        $msgs	= array();
        $msg	= "";
        $code 	= -1;
        $card_info ="";
        ///
        if(!$productID || !$cardPrice || !$quantity){
            $code           = -1;
            $msgs[]         = "Thông tin mua thẻ không hợp lệ.";
        }
        $data['catID']                  = "";
        $data['provider']               = "";
        $data['productID']		= $productID;
        $data['cardprice']		= $cardPrice;
        $data['quantity']		= $quantity;  
        $data['paymethod']              = "";
        //Save session                    
        $_SESSION['cardReceived']	= "-1";
        $_SESSION['pay']['store_info_init']	= $data;   
        //print_r($_SESSION['pay']['store_info_init']);exit;
        // Get Card Info
        $card_info			= $this->db_user_model->getCardProductsInfo($data['productID']);		
        if(!$card_info){
            $code           = -1;
            $msgs[]         = "Thông tin mua thẻ không hợp lệ.";
        }
        if(count($msgs)){            
            foreach ($msgs as $m){
                    $msg.="$m<br/>";			
            }
            $msg	= json_encode(array("code"=>$code,"msg"=>$msg));
            $this->smarty->assign("msg", json_decode($msg));
        }
        // end get session from epay
        $user_info = $this->session->userdata('user_info');
        if($user_info)
            $this->smarty->assign("user_info", $user_info);
        //
        $this->smarty->assign("card_info", $card_info);
        $this->smarty->assign("data", $data);
        $this->smarty->view('template/pages_live/partner','partner');
        $this->smarty->view('template/pages_live/shop_buycard','content');
        $this->smarty->display('template/frontend_live/home'); 
        /*
        $this->smarty                                        
                    ->assign("card_info"	, $card_info)
                    ->assign("data"		, $data)
                    ->display('template/shop/home');          
         */
    }		
	
    // SHOP TOPUP FONE WHEN NOT LOGINED
    public function paygate_topup($productID=null,$phonereceiver=null) {
        //        
        $msgs	= array();
        $msg	= "";
        $code 	= -1;
        $card_info ="";
        ///
        if(!$productID || !$phonereceiver ){
            $code           = -1;
            $msgs[]         = "Thông tin mua thẻ không hợp lệ.";
        }
        $data['catID']                  = "";
        $data['provider']               = "";
        $data['productID']		= $productID;
        $data['cardprice']		= $productID;
        $data['phonereceiver']		= $phonereceiver;
        $data['quantity']		= 1;  
        $data['paymethod']              = "";
        //Save session                    
        $_SESSION['cardReceived']	= "-1";
        $_SESSION['pay']['store_info_init']	= $data;   
        //print_r($_SESSION['pay']['store_info_init']);exit;        
        if(count($msgs)){            
            foreach ($msgs as $m){
                    $msg.="$m<br/>";			
            }
            $msg	= json_encode(array("code"=>$code,"msg"=>$msg));
            $this->smarty->assign("msg", json_decode($msg));
        }
        // end get session from epay
        $user_info = $this->session->userdata('user_info');
        if($user_info)
            $this->smarty->assign("user_info", $user_info);
        //
        $this->smarty->assign("card_info", $card_info);
        $this->smarty->assign("data", $data);
        $this->smarty->view('template/pages_live/partner','partner');
        $this->smarty->view('template/pages_live/shop_topup','content');
        $this->smarty->display('template/frontend_live/home'); 
        /*
        $this->smarty                                        
                    ->assign("card_info"	, $card_info)
                    ->assign("data"		, $data)
                    ->display('template/shop/home_topup');
         * 
         */
    }/////////////////////////////START BUY CARD BY EPAY///////////////////////////////             
        
   
}

/* End of file admin/cpanel.php */
/* Location: ./system/application/controllers/admin/cpanel.php */